<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!--  登陆界面  -->
<!DOCTYPE html>
<html>
<head>


    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="description" content="">
    <meta name="author" content="">
<title>彩妆  商城</title>
  <!-- Bootstrap Core CSS -->
    <link rel="stylesheet" href="/Shopping/static/css/bootstrap.min.css"  type="text/css">
	<link rel="stylesheet" href="/Shopping/static/css/font-slider.css"  type="text/css">
	<!-- Custom CSS -->
    <link rel="stylesheet" href="/Shopping/static/css/style.css">
	
	
	<!-- Custom Fonts -->
    <link rel="stylesheet" href="/Shopping/static/css/font-awesome.min.css"  type="text/css">
	
	<!-- jQuery and Modernizr-->
	<script src="/Shopping/static/js/jquery-2.1.1.js"></script>
		<script src="/Shopping/static/lib/layer/2.4/layer.js"></script>
	
	<!-- Core JavaScript Files -->  	 
    <script src="/Shopping/static/js/bootstrap.min.js"></script>
	

</head>
<body>
<nav id="top">
		<div class="container">
			<div class="row">
				<div class="col-xs-6">
	
				</div>
				<div class="col-xs-6">
					<ul class="top-link">
						<li><a href="/Shopping/Account/account"><span class="glyphicon glyphicon-user"></span> 登陆</a></li>
						<li><a href="/Shopping/Join/join"><span class="glyphicon glyphicon-envelope"></span> 注册</a></li>
					</ul>
				</div>
			</div>
		</div>
	</nav>
<!--Header-->
	<header class="container">
		<div class="row">
			<div class="col-md-4">
				<div id="logo">
					<font size="10" color="#cc3300" face="宋体"><i><strong>Shoopping</strong></i>
				</font></div>
			</div>
			<div class="col-md-4">
				<form class="form-search">  
					<input type="text" class="input-medium search-query">  
					<button type="submit" class="btn"><span class="glyphicon glyphicon-search"></span></button>  
				</form>
			</div>
			<div class="col-md-4">
				<div id="cart"><a  id="shopcart" class="btn btn-1" href="cart.html"><span class="glyphicon glyphicon-shopping-cart"></span>购物车</a></div>
			</div>
		</div>
	</header>
	<!--Navigation-->
    <nav id="menu" class="navbar">
		<div class="container">
			<div class="navbar-header"><span id="heading" class="visible-xs">目录</span>
			  <button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><i class="fa fa-bars"></i></button>
			</div>
			<div class="collapse navbar-collapse navbar-ex1-collapse">
				<ul class="nav navbar-nav">
					<li><a href="/Shopping/Category/category">首页</a></li>
				</ul>
			</div>
		</div>
	</nav>
	<!--//////////////////////////////////////////////////-->
	<!--///////////////////Account Page///////////////////-->
	<!--//////////////////////////////////////////////////-->
	<div id="page-content" class="single-page">
		<div class="container">
			<div class="row">
				<div class="col-lg-12">
					<ul class="breadcrumb">
						<li><a href="/Shopping/Category/category">首页</a></li>
						<li><a href="account.html">登陆</a></li>
					</ul>
				</div>
			</div>
			<div class="row" align="center">
				<div class="col-md-6" >
					<div class="heading"><h2>登陆</h2></div>
					<form name="form1" id="ff1" method="post" action="login.php">
						<div class="form-group">
							<input type="text" class="form-control" placeholder="账号id:" name="username" id="userName" required>
						</div>
						<div class="form-group">
							<input type="password" class="form-control" placeholder="密码:" name="email" id="password" required>
						</div>
						<button type="button" class="btn btn-1" name="login" id="login">登陆</button>
						
					</form>
				</div>
</body>
<script>
	$(document).ready(function(){
		login();
	});
	function validate(){ //验证输入的正确性
		
	}
	function login(){ //登陆
		$("#login").click(function(){
			$.ajax({
				url:"/Shopping/Account/validate",
				type:"get",
				dataType:"json",
				data:{"userName":$("#userName").val(),"password":$("#password").val()},
				async:false,
				success:function(data){
					if(data.res==1){
						//alert('success');
					    layer.msg('登陆成功',{icon:1,time:200000});
						window.location.href="${prePage}";
					
					}
					if(data.res==0){
						layer.msg('用户不存在',{icon:0,time:20000000});
					}
					if(data.res==2){
					
						layer.msg('密码错误',{icon:0,time:2000000});
					}
					
				},
				error:function(){
					alert('error');
				}
				
				
				
				
				
			});
		});
		
	}
	function clickShopcart(){//点击购物车按钮
		$("#shopcart").click(function(){
			if(!validateLogin()){ //未登录
				layer.msg('请您先登录',{icon:5,time:2000});
			} else {
				window.location.href="/Shopping/Shopcart/shopcart"
			}
		});
	}
	function validateLogin(){ //验证用户是否登录
		var res = false;
		$.ajax({
			url:"/Shopping/Login/validateLogin",
			type:"get",
			data:{},
			dataType:"json",
			async:false,
			success:function(data)
			{
				if(data.res==1){
				    //layer.msg('用户已登陆',{icon:1,time:2000});
					//window.location.href="${prePage}";
					res = true;
				}
				if(data.res==0){
				
					//layer.msg('用户未登陆',{icon:0,time:2000});
					res = false;
				}
			},
			error:function(){
				alert('error');
			}
			
		});
		return res;
	}


</script>
</html>